<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Live stream with MPD Patching</title>

    <script src="../../dist/modern/umd/dash.all.debug.js"></script>

    <!-- Bootstrap core CSS -->
    <link href="../lib/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="../lib/main.css" rel="stylesheet">

    <style>
        video {
            width: 100%;
        }

        .clock {
            color: #000;
            font-size: 60pt
        }
    </style>

    <script class="code">
        var outputContainer;

        function init() {
            var video,
                player,
                url = 'https://livesim2.dashif.org/livesim2/segtimeline_1/patch_60/testpic_2s/Manifest.mpd';

            video = document.querySelector('video');
            player = dashjs.MediaPlayer().create();
            player.initialize(video, url, true);
            outputContainer = document.getElementById('output-container');
            player.on('internalManifestLoaded', showEvent)
        }


        function showEvent(e) {
            outputContainer.innerHTML = "";
            for (var name in e) {

                if (typeof e[name] != 'object') {
                    log('    ' + name + ': ' + e[name]);
                }
            }
            for (name in e) {
                if (typeof e[name] == 'object') {
                    log('    ' + name + ':');
                    for (name2 in e[name]) {
                        log('        ' + name2 + ': ' + JSON.stringify(e[name][name2]));
                    }
                }
            }
        }

        function log(msg) {
            msg = msg.length > 90 ? msg.substring(0, 90) + '...' : msg;
            outputContainer.innerHTML += msg + '\n';
            outputContainer.scrollTop = outputContainer.scrollHeight;
        }
    </script>
</head>
<body>

<main>
    <div class="container py-4">
        <header class="pb-3 mb-4 border-bottom">
            <img class=""
                 src="../lib/img/dashjs-logo.png"
                 width="200">
        </header>
        <div class="row">
            <div class="col-md-6">
                <div class="h-100 p-5 bg-light border rounded-3">
                    <h3>Live stream with MPD Patching</h3>
                    <p>Example showing how dash.js handles live streams with updates to the manifest file provided via
                        MPD patches.</p>
                </div>
            </div>
        </div>
        <div class="row mt-4">
            <div class="col-md-7">
                <video controls="true"></video>
            </div>
        </div>
        <div class="row mt-4">
            <div class="col-md-12">
                <div class="p-5 border rounded-3 mt-1">
                    <h4>Last MPD update</h4>
                    <div id="output-container">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div id="code-output"></div>
            </div>
        </div>
        <footer class="pt-3 mt-4 text-muted border-top">
            &copy; DASH-IF
        </footer>
    </div>
</main>


<script>
    document.addEventListener('DOMContentLoaded', function () {
        init();
    });
</script>
<script src="../highlighter.js"></script>
</body>
</html>
